

## 列表去重排序,查找


### 这个方法没问过他 但是超过时间限制了’
def findDisappearedNumbers(self, nums):
    length = len(nums)
    results =  list(range(1,length+1))
    seen = set()
    nums = [x for x in nums if not (x in seen or seen.add(x))]
    
    for num in nums:
        if num in results:
            results.remove(num)
    return results
    

'''
1. results.remove(num) 太慢！⚠️
2、没必要去重

把 nums 放到 set中 然后遍历 1 到 n 加成哪个 数不在集合中

'''
def findDisappearedNumbers(self, nums):
    n = len(nums)
    nums = set(nums)
    result  = []
    
    for i in range(1,n+1):
        if i not in nums:
            result.append(i)
            
    return 


'''
空间换时间
两个set 直接 -
'''
def findDisappearedNumbers(self, nums):
    return list(set(range(1, len(nums) + 1)) - set(nums))